package conf

import (
	"encoding/json"
	"io"
	"os"

	"server/pkg/github.com/name5566/leaf/log"
)

var Server struct {
	LogLevel    string
	LogPath     string
	WSAddr      string
	CertFile    string
	KeyFile     string
	TCPAddr     string
	MaxConnNum  int
	ConsolePort int
	ProfilePath string
	MySqlUsr    string
	MySqlPwd    string
	DbName      string
	ServerID    int32
	HttpPort    string
}

func init() {
	// data, err := ioutil.ReadFile("conf/server.json")
	file, err := os.Open("conf/server.json")
	if err != nil {
		panic(err)
	}
	defer file.Close()
	data, err := io.ReadAll(file)
	if err != nil {
		log.Fatal("%v", err)
	}
	err = json.Unmarshal(data, &Server)
	if err != nil {
		log.Fatal("%v", err)
	}
}
